package com.trust.pams.dao.service.impl;

import com.mongodb.client.result.DeleteResult;
import com.trust.pams.dao.mongo.BaseMongoDaoImpl;
import com.trust.pams.dao.service.PamsSvnDao;
import com.trust.pams.dto.PamsQuoteDto;
import com.trust.pams.model.Tree.Tree;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class PamsSvnDaoImpl extends BaseMongoDaoImpl<Tree> implements PamsSvnDao {
    @Override
    public int batchPamsSvn(List<Tree> treeList) {
        super.insertAll(treeList);
        return 1;
    }

    @Override
    public DeleteResult deletePamsSvn(String projectGuid) {
        Query query = new Query();
        Criteria criteria = Criteria.where("projectGuid").is(projectGuid);
        query.addCriteria(criteria);
        return super.getMongoTemplate().remove(query,Tree.class);
    }

    @Override
    public List<Tree> getPamsSvn(String projectGuid) {
        Query dbQuery = new Query();
        dbQuery.addCriteria(Criteria.where("projectGuid").is(projectGuid));
        List<Tree> listData = find(dbQuery);
        return listData;
    }
}
